function V = x(A, B, C)

MA=mean(A);
MB=mean(B);
MC=mean(C);

%E = cat(1,A,B,C);
E = cat(1,A,B);

ME=mean(E);

CA=(length(A)-1)*cov(A);
CB=(length(B)-1)*cov(B);
%CC=(length(C)-1)*cov(C);


ST=(length(E)-1)*cov(E);

%SW=(CA+CB+CC);
SW=(CA+CB);

SB=ST-SW;

invSW=inv(SW);

tmp=invSW*SB;

[V,D] =eig(tmp);
V = D*V;

MD1=(length(A)-1)*(MA-ME)'*(MA-ME);
MD2=(length(B)-1)*(MB-ME)'*(MB-ME);
%MD3=(length(C)-1)*(MC-ME)'*(MC-ME);
 
%MD=MD1+MD2+MD3;
MD=MD1+MD2;


projC1 = V * A';
projC1 = projC1';

projC2 = V * B';
projC2 = projC2';

%projC3 = V * C';
%projC3 = projC3';

%hold on
%plot3(projC1(:,1), projC1(:,2), projC1(:,3) ,'rx')
%plot3(A(:,1), A(:,2), A(:,3) ,'bx')

%plot3(projC2(:,1), projC2(:,2), projC2(:,3) ,'co')
%plot3(B(:,1), B(:,2), B(:,3) ,'mx')

%plot3(projC3(:,1), projC3(:,2), projC3(:,3) ,'go')
%plot3(C(:,1),C(:,2), C(:,3) ,'y*')

end


